#libtest_common.so
CC = gcc
CXX = g++
CFLAGS = -g
INCLUDE = -I/lib/modules/2.6.18/source/include/ -I/usr/src/PF_RING/userland/lib -I/usr/include/libxml2 -I/usr/local/include
LIBS = -L /usr/lib -L . -lpthread -lpcre -lz -lxml2 -lpcap #-lLzclue #-l/usr/local/lib
SRCS = common.c entry.c webmail.c mail.c useragent.c mail_type.c imcommon.c gtalk.c imMsg.c web_yahoo_message.c web_popo.c caihong.c fetion.c
OBJS = common.o entry.o webmail.o mail.o useragent.o mail_type.o imcommon.o gtalk.o imMsg.o web_yahoo_message.o web_popo.o caihong.o fetion.o
HEADS = common.h mail_type.h PacketParser.h imcommon.h

all: libtest_common.so
libtest_common.so: $(SRCS) $(HEADS)
	$(CC) -g -fPIC -shared -o libtest_common.so $(SRCS) $(INCLUDE) $(LIBS)
	rm -f /usr/lib/libtest_common.so
	cp libtest_common.so /usr/lib


#XML_storer
#XML_LIBS = -L /usr/lib -L . -lboost_thread -lboost_regex -lz -lxml2 -lssl

#XML_SRCS  = XmlStorer.cpp Public.cpp PacketInfo.cpp
#XML_OBJS  = XmlStorer.o Public.o PacketInfo.o
#XML_HEADS = XmlStorer.h Public.h PacketInfo.h PacketParser.h
#libxml: $(XML_SRCS) $(XML_HEADS)
#	$(CXX) -g -fPIC -shared -o libxmlstorer.so $(XML_SRCS) $(INCLUDE) $(XML_LIBS)
#	rm -f /usr/lib/libxmlstorer.so
#	cp libxmlstorer.so /usr/lib


#demo
OBJS2 = demo
CFLAGS2 = -Wall -O -g
LIBS2 = -L /usr/lib -L . -lpcap -ltest_common -lpthread -lpcre -lz -lxml2

$(OBJS2) : $(OBJS2).o
	$(CC) $(CFLAGS2) $(OBJS2).o -o $(OBJS2) $(LIBS2)

$(OBJS2).o : $(OBJS2).c common.h 
	$(CC) $(CFLAGS2) $(OBJS2).c -c  
#	rm -rf *.o
.PHONY:clean
 
clean:
	rm -rf *.o demo libtest_common.so
